''''''

"""
dict2 = {"current": 1, 
         "limit": 20,
         "count": 449685,
         "list": [
             {"id": 1423085, "prodName": "大白菜", "prodCatid": 1181, "prodCat": "蔬菜"},
             {"id": 1423084, "prodName": "娃娃菜", "prodCatid": 1182, "prodCat": "蔬菜"},
             {"id": 1423083, "prodName": "小白菜", "prodCatid": 1183, "prodCat": "蔬菜"},
             {"id": 1423082, "prodName": "圆白菜", "prodCatid": 1184, "prodCat": "水果"},
         ]         
        }
提取出id，prodName，prodCatid，prodCat的值


请编写一个程序，用于统计字符串中每个字母的出现次数（字母忽略大小写），
统计出结果后，请按照{‘a’:3,‘b’:2}的格式输出

用户输入字符串
统一大小写
count()

字典的添加方法
字典[key] = value

"""
# 作业一
# dict2 = {"current": 1,
#          "limit": 20,
#          "count": 449685,
#          "list": [
#              {"id": 1423085, "prodName": "大白菜", "prodCatid": 1181, "prodCat": "蔬菜"},
#              {"id": 1423084, "prodName": "娃娃菜", "prodCatid": 1182, "prodCat": "蔬菜"},
#              {"id": 1423083, "prodName": "小白菜", "prodCatid": 1183, "prodCat": "蔬菜"},
#              {"id": 1423082, "prodName": "圆白菜", "prodCatid": 1184, "prodCat": "水果"},
#          ]
#          }
#
# for item in dict2["list"]:
#     Id = item['id']
#     prodName = item['prodName']
#     prodCatid = item['prodCatid']
#     prodCat = item['prodCat']
#
#     # Print or use the values as needed
#     print(f"id:{Id},prodName:{prodName},prodCatid:{prodCatid},prodCat:{prodCat}")
# 作业二


# def count_letters(input_string):
#     # 创建一个空字典用于存储字母出现次数
#     letter_count = {}
#
#     # 遍历字符串中的每个字符
#     for char in input_string:
#         # 忽略非字母字符
#         if char.isalpha():
#             # 将字母转换为小写
#             char = char.lower()
#
#             # 更新字母出现次数
#             if char in letter_count:
#                 letter_count[char] += 1
#             else:
#                 letter_count[char] = 1
#
#     return letter_count
#
#
# # 测试
# input_str = "Hello, World!"
# result = count_letters(input_str)
#
# # 按照要求的格式输出结果
# formatted_result = {k: v for k, v in result.items()}
# print(formatted_result)

"""
请编写一个程序，用于统计字符串中每个字母的出现次数（字母忽略大小写），
统计出结果后，请按照{‘a’:3,‘b’:2}的格式输出
"""

# 获取用户输入
user_input_string = input("请输入一个字符串")
# 将字符串转换为小写以进行大小写不敏感的统计
input_str = user_input_string.lower()
# 创建一个空字典存储字母出现的次数
letter_count = {}
# 遍历每个字符串
for char in input_str:
    # 过滤掉非字母字符
    if char.isalpha():
        letter_count.setdefault(char, 0)
        # print(letter_count.setdefault(char, 0))
        # print(char)
        letter_count[char] += 1

print(letter_count)
print("=============================")
# 指定格式化输出结果
res = dict(letter_count)
print(res)
